The Default CDEF is a simple aid for Macintosh programmers that draws default button outlines for any size buttons, in the proper color, in your application and in ResEdit dialog and alert templates. Push buttons, check boxes, and radio buttons can also be drawn using the window’s font.
___Instructions___
Default is a control definition function that you can copy and paste into your application. The Default CDEF enhances the System file’s standard control definition 0. If the last character of a button’s title is an ‘@’ (an at or an each symbol), the button is drawn with an outline indicating that it is the default button. The trailing ‘@’ is not drawn with the title.
If the button is inactive, the outline is grayed out. When Color QuickDraw is available, outlines are drawn in the same color as the button’s frame. If the Default CDEF is in the same file as your application’s DITL resources, ResEdit will display default button outlines drawn by Default. You do not need to write any code to use Default.
A dialog’s default button can be changed at any time in your application simply by changing the appropriate button titles. However, you, the programmer, are responsible for making sure there is only one default button. If you are not using a filterProc, Default makes sure that pressing the Return key or Enter key is the same as clicking in the default button. The default button is also highlighted when the Return key or Enter key is pressed. If you are using your own filterProc, you must perform these tasks.
If the last character of a control’s title is an ‘ƒ’, the control is drawn using the window’s current font. Push buttons, check boxes, and radio buttons will look the same as if you used a CNTL resource with the useWFont variation code. This feature is especially useful for CDEVs. If you need a default button that uses the window’s font, end the button’s title with ‘ƒ@’.
___Compatibility___
Default should work on any model of Macintosh with any System version. Default is 32-bit clean. Except for drawing the outline, Default lets the System file’s CDEF 0 do practically everything. Thus, Default’s buttons do anything that normal buttons do.
Be warned that Default uses the contrlData field of a ControlRecord (which is okay since it is reserved for CDEFs). If your application does something strange with this field, Default will not work.
When you drag or resize a default button in ResEdit, you may notice some slight flickering. This occurs because ResEdit does not know about the outline so Default forces ResEdit to refresh portions of the window. Default only behaves this way in ResEdit. This does not occur in normal applications. Default now comes in versions with and without the ResEdit updating code. This may be helpful if you are concerned about your application’s size.
___Bugs___
The outline will not update if the outline needs updating and the button does not, and UpdtControl or UpdtDialog is being used to update the controls. This problem does not occur with normal modal dialogs and occurs rarely with modeless dialogs. Unfortunately, there doesn’t seem to be a clean solution this problem. If you have this problem, you can call Draw1Control for the default button on every update event or simply use DrawControls or DrawDialog instead.
If you have a default button and you aren’t using a filterProc, pressing the Return key or Enter key will click in the default button even if the button is hidden. This is a bug in the Dialog Manager. If you have this problem, you must change the default button to a normal button before you call HideDItem or HideControl.
Please report any other bugs to any of the addresses listed below. Thanks to those programmers who did unusual things with their buttons, reported bugs, and helped make Default more robust.
___History___
1.0 — first release version
1.1 — fixed bug with HideControl and default buttons
1.2 — updated to support new 32-bit clean CDEF messages
1.3 — fixed bug with DragControl
1.4 — fixed bug converting between default buttons and normal buttons;
improved outlines for unusually sized default buttons
1.5 — forced ResEdit to refresh default buttons correctly
2.0 — added automatic Return and Enter support for default buttons;
added window font feature for push buttons, check boxes, and radio buttons;
restructured code to reduce size of CDEF
2.1 — updated to follow Apple’s new way of drawing default outlines
___Distribution___
Default is copyrighted but it is also available free of charge. You may copy and redistribute Default provided that this documentation accompanies any redistributed copies of Default and the Default CDEF is not modified in any way.
You may include Default in any commercial or non-commercial software that you distribute provided that the Default CDEF is not modified in any way and that Lim Unlimited is given a free, fully functional, and fully supported copy of your software. You are not required to include a copyright notice for Default in your software.
The source code to Default is now available on request. You can get a copy via electronic mail or by sending a stamped self-addressed envelope and a disk via postal mail. The source code may not be redistributed without the permission of Lim Unlimited. You may not distribute modified versions of the source code or any software derived from the source code.